﻿# Once done, this will define
#
# TINY_CURL_INCLUDE_DIR - theTINY_CURL include directory
# TINY_CURL_LIBRARY_DIR - theTINY_CURL library directory
# TINY_CURL_LIBS - link these to useTINY_CURL
#
#  ......

MACRO(LOAD_LIBTINY_CURL os arch)
    MESSAGE(INFO "--------------------------------")
    SET(3RDPARTY_DIR ${PROJECT_SOURCE_DIR}/3rdparty/target/${${os}}_${${arch}})
    MESSAGE(STATUS "3RDPARTY_DIR: ${3RDPARTY_DIR}")
    #FIND_FILE(TINY_CURL_INCLUDE_DIR include ${3RDPARTY_DIR} NO_DEFAULT_PATH)
    #FIND_FILE(TINY_CURL_LIBRARY_DIR lib ${3RDPARTY_DIR} NO_DEFAULT_PATH)
    SET(TINY_CURL_INCLUDE_DIR ${3RDPARTY_DIR}/include/tiny_curl)
    SET(TINY_CURL_LIBRARY_DIR ${3RDPARTY_DIR}/lib/tiny_curl)

    IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
        SET(TINY_CURL_LIBS 
		m
		z
		${TINY_CURL_LIBRARY_DIR}/libwolfssl.a 
		${TINY_CURL_LIBRARY_DIR}/libcurl.a
		pthread
		)
    ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
        SET(TINY_CURL_LIBS  
		m
		z
		${TINY_CURL_LIBRARY_DIR}/libwolfssl.a 
		${TINY_CURL_LIBRARY_DIR}/libcurl.a
		pthread
		)
    ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")

    IF(TINY_CURL_INCLUDE_DIR)
        #SET(TINY_CURL_LIBS "${TINY_CURL_LIBRARY_DIR}/libcurl.a")
        MESSAGE(STATUS "TINY_CURL_INCLUDE_DIR : ${TINY_CURL_INCLUDE_DIR}")
        MESSAGE(STATUS "TINY_CURL_LIBRARY_DIR : ${TINY_CURL_LIBRARY_DIR}")
        MESSAGE(STATUS "TINY_CURL_LIBS : ${TINY_CURL_LIBS}")
    ELSE()
        MESSAGE(FATAL_ERROR "tiny_curl not found!")
    ENDIF()
ENDMACRO()
